import 'package:flutter/material.dart';
// import 'package:flutter_html/style.dart';
// import 'package:sports/res/colours.dart';
// import 'package:sports/res/styles.dart';
import 'package:sports_new/resources/colours.dart';
import 'package:sports_new/resources/styles.dart';

import 'qkd_text.dart';
// import 'package:motoilet/res/colours.dart';

class QkdButton extends StatelessWidget {
  const QkdButton({
    super.key,
    this.text = '',
    this.widget,
    this.textStyle = const TextStyle(fontSize: 16, fontWeight: FontWeight.w400),
    this.foregroundColor,
    this.backgroundColor,
    this.height = 44.0,
    this.width,
    this.borderRadius,
    this.borderSide = BorderSide.none,
    this.padding = EdgeInsets.zero,
    required this.onPressed, this.strutStyle, this.enable = true,
  });

  const QkdButton.large(
      {super.key,
      this.text = '',
      this.widget,
      this.textStyle =
          const TextStyle(fontSize: 16, fontWeight: FontWeight.w400),
      this.foregroundColor = Colours.white,
      this.backgroundColor = Colours.main,
      this.height = 44.0,
      this.width = double.infinity,
      // this.padding = const EdgeInsets.symmetric(horizontal: 16.0),
      this.borderRadius = 4,
      this.borderSide = BorderSide.none,
      this.padding = EdgeInsets.zero,
      required this.onPressed, this.strutStyle,
      this.enable = true});

  final Widget? widget;
  final String? text;
  final TextStyle? textStyle;
  final StrutStyle? strutStyle;
  final Color? foregroundColor;
  final Color? backgroundColor;
  final double? height;
  final double? width;
  final double? borderRadius;
  final VoidCallback? onPressed;
  final EdgeInsets? padding;
  final bool enable;

  final BorderSide borderSide;

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      height: height,
      width: width,
      child: Opacity(
        opacity: enable?1:0.4,
        child: TextButton(
          onPressed: enable?onPressed:null,
          style: ButtonStyle(
            foregroundColor: MaterialStateProperty.resolveWith(
              (states) {
                if (foregroundColor != null) {
                  return foregroundColor;
                } else {
                  return Colours.main;
                }
              },
            ),
            backgroundColor: MaterialStateProperty.resolveWith((states) {
              if (backgroundColor != null) {
                return backgroundColor;
              } else {
                return Colours.transparent;
              }
            }),
            minimumSize: (width == null || height == null)
                ? null
                : MaterialStateProperty.all<Size>(Size(width!, height!)),
            shape: MaterialStateProperty.all<OutlinedBorder>(
              RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(borderRadius ?? height! / 2),
              ),
            ),
            side: MaterialStateProperty.all<BorderSide>(borderSide),
            padding: MaterialStateProperty.all(padding),
          ),
          child: widget == null
              ? QkdText.style(
                  text ?? '',
                  style: textStyle,
                  needCenter: strutStyle != null,
                )
              : Center(child: widget!),
        ),
      ),
    );
  }
}
